package com.qolome.order.controller;

import java.util.Arrays;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qolome.order.config.BaseConfigProperties;
import com.qolome.product.dto.request.CartDTO;
import com.qolome.product.dto.response.ProductInfoResponseDto;
import com.qolome.product.feign.ProductFeign;

/**
 * @author Qolome
 * @version V1.0
 * @Description 客户端
 * @date 2020年 01月20日 12:04:18
 */
@RestController
public class ClientController {

    @Autowired
    ProductFeign productFeign;
    
    @Autowired
    BaseConfigProperties baseConfigProperties;

    @GetMapping("/getMsg")
    public  String getMsg(){
        return productFeign.msg();

    }
    
    @GetMapping("/getProductList")
    public  List<ProductInfoResponseDto> getProductList(){
        return productFeign.listForOrder(Arrays.asList("101","102"));

    }
    
    @GetMapping("/productDecreaseStock")
    public String productDecreaseStock() {
    	productFeign.decreaseStock(Arrays.asList(new CartDTO("103", 3)));
        return "ok";
    }
    
    @GetMapping("/getConfig")
    public String getConfig() {
    	return String.format("order的名字是 %s,今年%s岁", baseConfigProperties.getName(),baseConfigProperties.getAge());
    }
}
